package com.easysoft.framework.action;

import com.easysoft.framework.beans.Page;
import com.easysoft.framework.consult.model.SysConsultationQuery;
import com.easysoft.framework.consult.model.SysConsultationReplyQuery;
import com.easysoft.framework.consult.model.SysConsultationReplyView;
import com.easysoft.framework.consult.model.SysConsultationView;
import com.easysoft.framework.consult.service.SysConsultationReplyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * Created by try on 2017/9/12.
 *
 * 咨询回复模块
 */
@RestController
@RequestMapping(value = SystemConsultationReplyAction.BASE_VIEW)
public class SystemConsultationReplyAction {
    public static final String BASE_VIEW = "/consult";
    private static final Logger logger = LoggerFactory.getLogger(SystemConsultationReplyAction.class);


    @Autowired
    @Qualifier("service.SysConsultationReplyService")
    private SysConsultationReplyService sysConsultationReplyService;
    /**
     * 分页回复模块
     * @param page  分页信息
     * @param query 查询条件
     * @return 咨询回复模块
     */
    @RequestMapping(value = "/listConsultationReply", method = {RequestMethod.POST, RequestMethod.GET})
    public ModelAndView listConsultationReply(Page page, SysConsultationReplyQuery query) {
        logger.info("Call SystemConsultationReplyAction.listConsultationReply({},{})", page.toString(), query.toString());
        List<SysConsultationReplyView> list = sysConsultationReplyService.selectSysConsultationReplyListByPage(query,page);
        ModelAndView mv = new ModelAndView(BASE_VIEW + "/listConsultationReply");
        mv.addObject("page", page);
        mv.addObject("query", query);
        mv.addObject("listConsultationReply", list);
        return mv;
    }


}
